import { Link } from 'umi';
import { Space, Popconfirm } from 'antd';
import { getOrganizationType, getSchoolType } from '@/utils/Common'

const columns = (delAction) => {
  return [
    {
      title: '机构名称',
      key: 'name',
      dataIndex: 'name'
    },
    {
      title: '学校地址',
      key: 'address',
      dataIndex: 'address'
    },
    {
      title: '所属市',
      key: 'cityName',
      dataIndex: 'cityName',
      align: 'center'
    },
    {
      title: '所属区县',
      key: 'countyName',
      dataIndex: 'countyName',
      align: 'center'
    },
    {
      title: '机构类型',
      key: 'type',
      dataIndex: 'type',
      align: 'center',
      render: (text) => {
        const info = getOrganizationType(text);
        return info ? info.name : null;
      }
    },
    {
      title: '学校类型',
      key: 'subType',
      dataIndex: 'subType',
      align: 'center',
      render: (text) => {
        const info = getSchoolType(text);
        return info ? info.name : null;
      }
    },
    {
      title: '创建时间',
      key: 'createTime',
      dataIndex: 'createTime',
      align: 'center',
      sorter: (a, b) => new Date(a.createTime).getTime() - new Date(b.createTime).getTime()
    },
    {
      title: '操作',
      key: 'action',
      fixed: 'right',
      align: 'center',
      render: (text, record) => (
        <Space size="middle">
          <Link to={{ pathname: `/management/school/modify`, query: { id: record.id } }}>修改</Link>
          <Popconfirm
            title="确定要删除此预算吗?"
            onConfirm={() => { delAction ? delAction(row.id) : null }}
            okText="确定"
            cancelText="取消">
            <a>删除</a>
          </Popconfirm >
        </Space>
      )
    }
  ]
} 

export default columns